DEFINITION MODULE AEScalls;

(*
 *  Copyright (c) 1987,1988,1989 by
 *  ana-systems, Foster City, California.
 *  All Rights Reserved.
 *
 *  This software is furnished under a license and may be used and copied
 *  only  in accordance with  the  terms  of  such  license and  with the
 *  inclusion of the above copyright notice.  This software or  any other
 *  copies thereof may not be provided or otherwise made available to any
 *  other  person.   No title to and ownership of the  software is  herby
 *  transferred.
 *
 *  The information in this software is  subject to change without notice
 *  and  should  not be construed as a commitment by ana-systems.   No
 *  warranty is implied or expressed.
 *)

FROM SYSTEM IMPORT ADDRESS;

EXPORT QUALIFIED GrafHandle,ApplExit,FormAlert,RsrcLoad,RsrcGaddr,
                 RsrcFree,MenuBar,EvntMulti,MenuTNormal,GrafMouse,
                 FselInput,FormDo,FormDial,FormCenter,ObjcDraw,ObjcChange,
                 FormError,MenuIEnable,GrafMKState;

PROCEDURE GrafHandle(VAR cellW,cellH,boxW,boxH:INTEGER):INTEGER;
(*
 *  Returns the physHandle and places the size, in pixels,
 *  of a character cell and character box in the VAR parameters.
 *)
 
PROCEDURE ApplExit():INTEGER;
(*
 *  Notify AES the application is closing.
 *  Returns 0 for error and >0 for success.
 *)
 
PROCEDURE FormAlert(defBtn:INTEGER; VAR aString:ARRAY OF CHAR):INTEGER;
(*
 *  Dispay an alert box.  Parameters are default button and 
 *  alert message.  Returns the number of the button used for exit.
 *
 *  defBtn may be 1, 2, or 3 depending on the number of buttons.
 *  aString must have the form "[ icon num ][ message ][ button(s) ]".
 *)

PROCEDURE FormError(error:INTEGER);
(*
 *  Display an error message appropriate to the error number passed.
 *)

PROCEDURE RsrcLoad(VAR resFname:ARRAY OF CHAR):INTEGER;
(*
 *  Load resource file 'resFname' into memory.
 *  Returns 0 for error and >0 for success.
 *)
 
PROCEDURE RsrcGaddr(resType,resIndex:INTEGER; VAR resaddr:ADDRESS):INTEGER;
(*
 *  Get address of a particular object within the file. resType is the
 *  type of object; resIndex is its position within the object tree.
 *  Returns 0 for error and >0 for success.
 *)

PROCEDURE RsrcFree():INTEGER;
(*
 *  Dump the resource file and free its memory.
 *  Returns 0 for error and >0 for success.
 *)

PROCEDURE MenuBar(mnTree:ADDRESS; mnFlag:INTEGER):INTEGER;
(*
 *  Display or erase a menubar.  mnFlag=0  erase menu
 *                               mnFlag=1  show menu
 *  Returns 0 for error and >0 for success.
 *)

PROCEDURE MenuIEnable(mnTree:ADDRESS; mnItem,mnSetting:INTEGER):INTEGER;
(*
 *  Disable of enable a menu item.  mnFlag=0  disable
 *                                  mnFlag=1  enable
 *  Returns 0 for error and >0 for success.
 *)

PROCEDURE EvntMulti(evFlags,bClicks,bMask,bState,
                    m1Flag,m1X,m1Y,m1Width,m1Height,
                    m2Flag,m2X,m2Y,m2Width,m2Height:INTEGER;
                    VAR msgBuf:ARRAY OF INTEGER;
                    timerLo,timerHi:INTEGER;
                    VAR mouseX,mouseY,mouseBtn,keyState,
                    keyReturn,clickReturn:INTEGER):INTEGER;
(*
 *  Wait for any of the events specified in the evflags variable.
 *  Return the events.
 *)                    

PROCEDURE MenuTNormal(mnTree:ADDRESS; mnTitle,mnNormal:INTEGER):INTEGER;
(*
 *  Use to highlight or de-highlight menu titles.
 *  mnNormal=0 highlight
 *          =1 de-highlight
 *  Returns 0 for error and >0 for success.
 *)

PROCEDURE GrafMouse(formNum:INTEGER; formDef:ADDRESS):INTEGER;
(*
 *  Change the mouse form.  formNum=256 to turn mouse off
 *                                 =257 to turn mouse on
 *                                 =0   to make arrow shape
 *                                      ( and others... )
 *  Set formDef NIL if a predefined shape is used.
 *  Returns 0 for error and >0 for success.
 *)

PROCEDURE FselInput(VAR defPath,defFname:ARRAY OF CHAR;
                    VAR button:INTEGER):INTEGER;
(*
 *  Display the standard Item Selector with path and filename
 *  provided.  Returns path and filename choosen, along with
 *  button choosen: 0=cancel, 1=Ok.
 *  Returns 0 for error and >0 for success.
 *)

PROCEDURE FormDo(dlogTree:ADDRESS; startObj:INTEGER):INTEGER;
(*
 *  Handles interaction with dialog box.  Returns exit object.
 *)
 
PROCEDURE FormDial(formCmd,smallX,smallY,smallW,smallH,
                   bigX,bigY,bigW,bigH:INTEGER):INTEGER;
(*
 *  Reserves or dumps screen space for dialog box.  Also can
 *  draw expanding or shrinking box.  The 'big_' parameters
 *  indicate the size of the box which you can get from
 *  FormCenter().  formCmd tell what you want to do with the box.
 *  Returns 0 for error and >0 for success.
 *)
 
PROCEDURE FormCenter(dlogTree:ADDRESS; VAR newX,newY,newW,newH:INTEGER);
(*
 *  Calculates position for centering box; returns these values
 *  and puts them in the box's object record.
 *)
 
PROCEDURE ObjcDraw(objTree:ADDRESS; objStart,objDepth,
                   clipX,clipY,clipW,clipH:INTEGER):INTEGER;
(*
 *  Draw objDepth number of object levels in objTree, starting with
 *  objStart.  Must specify the clipping rectangle.
 *  Returns 0 for error and >0 for success.
 *)
 
PROCEDURE ObjcChange(objTree:ADDRESS; objc,resvd,clipX,clipY,clipW,clipH,
                     newstate,redraw:INTEGER):INTEGER;
(*
 *  Change the state of an object (as in a dialog box).
 *  Returns 0 for error and >0 for success.
 *)

PROCEDURE GrafMKState(VAR mouseX,mouseY,
                          mouseBut,keyState:INTEGER):INTEGER;
(*
 *  Provides the current mouse position, mouse button state,
 *  and shift/control/alt key state.
 *)

END AEScalls.
